package chalmers.game.subterranean.model.items;

import chalmers.game.subterranean.model.world.IWorld;
import chalmers.game.subterranean.util.Direction;
import chalmers.game.subterranean.util.Position;
import lombok.Getter;
import lombok.Setter;
import org.apache.log4j.Logger;

/**
 * User: Mikael Friederici Date: 2014-05-17 Time: 00:26
 */
public class Ladder implements IEquippableItem {

    private static final Logger logger = Logger.getLogger("subLog");
    IWorld world;
    public final String name = "Ladder";

    private @Getter @Setter
    int amount = 100; // TODO dummy value.

    public Ladder(IWorld world) {
        this.world = world;
    }

    @Override
    public void action(Position position, Direction direction) {
        if (amount > 0) {
            if (world.addLadderBlock(position)) {
                amount--;
            }
        } else {
            logger.info("Error: you have no ladder blocks left.");
        }
    }

    @Override
    public String toString() {
        return name;
    }
}
